#include <iostream>
#include <vector>
#include <stack>

using namespace std;

class Solution
{
public:
  int maximalRectangle(vector<vector<char>> &matrix)
  {
    if (0 == matrix.size())
      return 0;
    int rows = matrix.size(), cols = matrix[0].size();
    vector<int> heights(cols, 0);
    int res = 0;
    // 每一行看成一个直方图
    for (int i = 0; i < rows; i++)
    {
      for (int j = 0; j < cols; j++)
      {
        if ('1' == matrix[i][j])
        {
          heights[j] = heights[j] + matrix[i][j] - '0';
        }
        else
        {
          heights[j] = 0;
        }
      }
      res = max(res, maxRec(heights));
    }
    return res;
  }

private:
#不要传引用
  int maxRec(vector<int> heights)
  {
    //int size = heights.size();
    if (0 == heights.size())
      return 0;
    if (1 == heights.size())
      return heights[0];

    heights.insert(heights.begin(), 0);
    heights.push_back(0);
    stack<int> stk;
    stk.push(0);

    int res = 0;
    // 线性扫描建立单调栈 递增
    for (int i = 1; i < heights.size(); i++)
    {
      while (!stk.empty() && heights[i] < heights[stk.top()])
      {
        // 找栈顶的左右边界
        int height = heights[stk.top()];
        stk.pop();

        // 左边界为当前top()
        int length = (i - stk.top() - 1);
        res = max(res, height * length);
      }
      stk.push(i);
    }
    return res;
  }
};

int main()
{

  int n;
  while (cin >> n) // 输入矩阵的行数
  {

    vector<vector<char>> string_vector;
    for (int i = 0; i < n; i++)
    {
      string str;
      cin >> str;
      int size = str.size();
      vector<char> s(size);
      for (int j = 0; j < str.size(); j++)
      {
        s[j] = str[j];
      }
      string_vector.push_back(s);
    }

    Solution solute;
    cout << solute.maximalRectangle(string_vector) << endl;
  }

  return 0;
}